<template>
  <view style="display: flex; flex-direction: column; height: 100vh">
	  <xmInfo
		v-if="itemContent"
	    :projectno="itemContent.projectno"
	    :projectname="itemContent.projectname"
	  ></xmInfo>
    <view style="flex: 1; overflow: scroll" v-if="itemContent">
      
      <view class="margin padding xm-title">
        <form>
          <view class="cu-form-group">
            <view class="title">申请主体</view>
            <view>{{ itemContent.applybodyname }}</view>
          </view>
          <view class="cu-form-group">
            <view class="title">联系人</view>
            <view>{{ itemContent.contacts }}</view>
          </view>
          <view class="cu-form-group">
            <view class="title">联系电话</view>
            <view>{{ itemContent.mobile }}</view>
          </view>
          <view class="cu-form-group">
            <view class="title">工程类型</view>
            <view>{{ itemContent.firstbusinessname }}</view>
          </view>
          <view class="cu-form-group">
            <view class="title">安装地址</view>
            <view>{{ itemContent.projectaddress }}</view>
          </view>
          <view class="cu-form-group">
            <view class="title">接件时间</view>
            <view>{{ itemContent.createtime }}</view>
            <!-- <view><input placeholder="整改结果" name="input" v-model="dataInfo.zhenggaiResult" :focus="true" class="input-align"></input></view> -->
          </view>
          <view class="cu-form-group">
            <view class="title">设计人员</view>
            <view>{{ itemContent.designer }}</view>
          </view>
          <view class="cu-form-group">
            <view class="title">预算人员</view>
            <view>{{ itemContent.budgetor }}</view>
          </view>
          <view class="cu-form-group"  v-if="itemContent && itemContent.pmZone && itemContent.pmZone.pmContractor">
            <view class="title">承包商</view>
            <view>{{ itemContent.pmZone.pmContractor.name }}</view>
          </view>
          <view class="cu-form-group"  v-if="itemContent && itemContent.pmZone && itemContent.pmZone.pmContractor">
            <view class="title">施工人员</view>
            <view>{{ itemContent.pmZone.contacts }}</view>
          </view>
          <view class="cu-form-group"  v-if="itemContent && itemContent.pmZone && itemContent.pmZone.pmContractor">
            <view class="title">施工人员电话</view>
            <view>{{ itemContent.pmZone.phone }}</view>
          </view>
          <view class="cu-form-group" v-if="itemContent && itemContent.pmZone && itemContent.pmZone.leaderUser">
            <view class="title">项目负责人</view>
            <view>{{ itemContent.pmZone.leaderUser.userName }}</view>
          </view>
          <view class="cu-form-group" v-if="itemContent && itemContent.pmZone && itemContent.pmZone.techUser">
            <view class="title">技术负责人</view>
            <view>{{ itemContent.pmZone.techUser.userName }}</view>
          </view>
		  <view class="cu-form-group" v-if="itemContent && itemContent.pmZone && itemContent.pmZone.securityUser">
            <view class="title">安全负责人</view>
            <view>{{ itemContent.pmZone.securityUser.userName }}</view>
          </view>
		  <view class="cu-form-group" v-if="itemContent && itemContent.pmZone && itemContent.pmZone.materialUser">
            <view class="title">材料负责人</view>
            <view>{{ itemContent.pmZone.materialUser.userName }}</view>
          </view>
		  <view class="cu-form-group" v-if="itemContent && itemContent.pmZone && itemContent.pmZone.dataUser">
            <view class="title">资料负责人</view>
            <view>{{ itemContent.pmZone.dataUser.userName }}</view>
          </view>
		  <view class="cu-form-group" v-if="itemContent && itemContent.pmZone && itemContent.pmZone.pmSupervision">
            <view class="title">监理</view>
            <view>{{ itemContent.pmZone.pmSupervision.name}}</view>
          </view>
		  <view class="cu-form-group" >
            <view class="title">实际/预计工期</view>
            <view>{{ itemContent.actualduration + '/'}}  {{ itemContent.pmZone.plannedduration || ''}}</view>
          </view>
		  <view class="cu-form-group" >
            <view class="title">项目特征</view>
            <view>{{ itemContent.projecttype || ''}}</view>
          </view>
		  <view class="cu-form-group">
            <view class="title">任务分配备注</view>
            <view>{{ itemContent.pmZone.remarks || ''}}</view>
          </view>
        </form>
      </view>
    </view>
	<!-- <view style="height: 80px"></view>
    <view class="cu-bar foot">
      <u-grid :col="4">
        <u-grid-item>
          <u-icon name="/static/image/dk.png" :size="46"></u-icon>
          <view
            class="grid-text"
            style="color: #666666; margin-top: 5px; font-size: 12px"
            >打卡</view
          >
        </u-grid-item>
        <u-grid-item @click="starChange(itemContent)">
		  <u-icon
            name="star-fill"
            :color="itemContent.isStar ? '#aaaaaa' : '#F3B421'"
            size="46"
          ></u-icon
        >
          <view
            class="grid-text"
            style="color: #666666; margin-top: 5px; font-size: 12px"
            >{{ itemContent.isStar ? "收藏" : "取消收藏" }}</view
          >
        </u-grid-item>
        <u-grid-item>
          <u-icon name="/static/image/bj.png" :size="46"></u-icon>
          <view
            class="grid-text"
            style="color: #666666; margin-top: 5px; font-size: 12px"
            >编辑</view
          >
        </u-grid-item>
        <u-grid-item>
          <u-icon name="/static/image/gd.png" :size="46"></u-icon>
          <view
            class="grid-text"
            style="color: #666666; margin-top: 5px; font-size: 12px"
            >工程日志</view
          >
        </u-grid-item>
      </u-grid>
    </view> -->
  </view>
</template>
<script>
import xmInfo from "@/pages/zfgs/index/componetns/xmInfo.vue";
export default {
  components: {
    xmInfo,
  },
  data() {
    return {
      list: [],
      dataInfo: {},
      current: 0,
      keyword: "",
      itemContent: '',
    };
  },
  created() {},
  onLoad(e) {
    if (typeof e.item !== "undefined") {
      try {
        let obj = JSON.parse(e.item);
		this.$u.api.zfgs.pmProjectinformationForm({id:obj.id}).then(res=>{
			this.itemContent = res.pmProjectinformation
		})
      } catch (error) {
        console.error("Failed to parse item:", error);
      }
    } else {
      console.warn("Item is undefined.");
    }
  },
  methods: {
	starChange(item) {
      // item.states = !item.states;
      if(item.isStar){
        this.$u.api.zfgs.collectSave({
          projectCode: item.projectno,
          projectName: item.projectname,
        }).then((res) => {
            if(res.result == 'true'){
              item.isStar = !item.isStar;
              this.$u.toast('收藏成功');
            }else{
              this.$u.toast(res.message);
            }
        });
      }else{
        this.$u.api.zfgs.collectCancel({
          projectCode: item.projectno,
        }).then((res) => {
          if(res.result == 'true'){
              item.isStar = !item.isStar;
              this.$u.toast('取消收藏');
            }else{
              this.$u.toast(res.message);
            }
        });        
      }
    },
    change(index) {
      this.current = index;
    },
  },
};
</script>
<style scoped lang="scss">
.cu-item {
  width: 41% !important;
  height: 90px;
}

.cuIcon-cardboardfill {
  margin-top: 20px !important;
}

.xm-title {
  border-radius: 20rpx;
  font-size: 30rpx;
  background-color: #fff;
  // background-image: url("/static/image/zfgs/index/icon@2x.png");
  background-repeat: no-repeat;
  background-size: 38rpx 42rpx;
  background-position: 10rpx 10rpx;
  position: relative;

  .xm-title-p1 {
    color: #999999;
    font-size: 30rpx;
    line-height: 40rpx;
  }

  .xm-title-p2 {
    color: #3d3d3d;
    line-height: 48rpx;
    font-weight: bold;
  }

  .xm-title-img {
    width: 38rpx;
    height: 42rpx;
    position: absolute;
    top: 0;
    right: 32rpx;
  }
}

.xm-item-1 {
  font-size: 34rpx;
  color: #3d3d3d;
  line-height: 40rpx;
  position: relative;
  margin-bottom: 26rpx;
}

.xm-item-1::after {
  content: "";
  display: inline-block;
  position: absolute;
  width: 26rpx;
  height: 4rpx;
  background-color: #bbbbbb;
  bottom: -16rpx;
  left: 0;
}

.xm-item {
  margin-right: 72rpx;
}

.radius {
  border-radius: 20rpx;
}

.xm-item-2 {
  font-size: 28rpx;
  color: #999999;
}

.action {
  color: #303133;
}

.title {
  flex-shrink: 0;
  color: #999999;
}

.text-sl {
  font-size: 22px !important;
}

.cu-bar {
  min-height: 80px;
}

.cu-btn {
  font-size: 16px;
  height: 40px;
}

.foot {
  z-index: 997;
  background: #fff;
}

.green {
  color: green;
}

.input-align {
  text-align: right;
}
</style>